package com.srt.util.service;

import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * @name: ExistsConditionBuilder
 * @author: rd07
 * @date: 2020/8/13
 * @time: 10:11
 */
@Getter
public class ExistsConditionBuilder<T> {

    private List<ExistsCondition<T>> conditions;

    public ExistsConditionBuilder() {
        conditions = new ArrayList<>();
    }

    /**
     * 添加条件
     *
     * @param condition
     * @return
     */
    public ExistsConditionBuilder append(ExistsCondition<T> condition) {
        conditions.add(condition);
        return this;
    }

    /**
     * 添加条件
     *
     * @param sFunction
     * @param value
     * @return
     */
    public ExistsConditionBuilder append(SFunction<T, ?> sFunction, Object value) {
        conditions.add(new ExistsCondition<>(sFunction, value));
        return this;
    }
}
